﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;

namespace HJT212_Protocol_Server.DAO
{
    public class HostClientDao
    {
        private static string connStr = ConfigurationManager.AppSettings["connStr"];

        /// <summary>
        /// 凭借MN号和密码，是否能够正确登陆
        /// </summary>
        /// <param name="MN">MN号</param>
        /// <param name="PW">密码</param>
        /// <returns>是否可以正常登陆</returns>
        public bool IsRightLogin(string MN, string PW)
        {
            try
            {
                if (string.IsNullOrEmpty(MN)) return false;
                string sqlSelect = " select FIRST 1 MN, MCNName,PW from TB_HOSTCLIENTS WHERE MN='{0}' AND PW='{1}' ";
                sqlSelect = string.Format(sqlSelect, MN, PW);
                FirebirdHelper helper = new FirebirdHelper(connStr);
                DataTable dt = helper.Data_Table(sqlSelect);
                if (dt != null && dt.Rows.Count > 0)
                {
                    return true;
                }
            }
            catch (Exception ex)
            {

                throw;
            }
            return false;
        }
    }
}
